package com.cxka.payment;

import cn.hutool.core.util.StrUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.core.env.Environment;

import java.net.InetAddress;
import java.net.UnknownHostException;


/**
 * <p>
 * 启动类
 * </p>
 *
 * @author ljklxm
 * @email 1129126518@qq.com
 * @since 2021-07-26
 */
@Slf4j
@SpringBootApplication(exclude = DataSourceAutoConfiguration.class)
@ComponentScan("com.cxka.*.*")
public class PaymentApplication {

    public static void main(String[] args) {

        ConfigurableApplicationContext application = SpringApplication.run(PaymentApplication.class, args);
        Environment env = application.getEnvironment();
        String ip = null;
        try {
            ip = InetAddress.getLocalHost().getHostAddress();
        } catch (UnknownHostException e) {
            e.printStackTrace();
            ip = "unknown";
        }
        String profile = env.getProperty("spring.profiles.active");
        String applicationName = env.getProperty("spring.application.name");
        String port = env.getProperty("server.port");
        String path = StrUtil.nullToEmpty(env.getProperty("server.servlet.context-path"));
        log.info("\n" +
                        "-------------------------------------------------------------\n" +
                        "\tService:    :\t{}\n" +
                        "\tProfile     :\t{}\n" +
                        "\tLocal URL   :\thttp://localhost:{}{}\n" +
                        "\tExternal URL:\thttp://{}:{}{}\n" +
                        "\tApi Doc URL :\thttp://{}:{}{}/doc.html\n" +
                        "-------------------------------------------------------------",
                applicationName,
                profile,
                port, path,
                ip, port, path,
                ip, port, path);

    }
}
